<?php

/**
* 导航分类控制器
*/
class CommonController extends Controller{
	protected $model;
	protected $allCate;
	public function __init(){
		parent::__init();
		$this->model=K('Category');
	}
    /*
     * 导航分类数据分配
     */
    public function topNav(){
		$this->allCate=$this->model->getField('cid,cname,pid',true);
		$temp=array();
		foreach ($this->allCate as $k => $v) {
			$temp[$v['pid']][]=$v;
		}
		$cateTree=$temp[0];
		foreach ($cateTree as $k => $v) {
			$cateTree[$k]['son']=$temp[$v['cid']];
			foreach ($cateTree[$k]['son'] as $key => $value) {
				if(isset($temp[$value['cid']])) $cateTree[$k]['son'][$key]['sec']=$temp[$value['cid']];
			}
		}
		$this->assign('navCate',$cateTree);
    }
	
	




}
    
    
    
?>